package com.video.main_video.manager.handle.collections;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.video.main_video.api.Api;
import com.video.main_video.common.staticData.StaticData;
import com.video.main_video.dao.entity.Collections;
import com.video.main_video.dao.entity.User;
import com.video.main_video.dao.request.collection.CollectionGetListRequest;
import com.video.main_video.dao.response.collection.CollectionsGetListResponse;
import com.video.main_video.manager.handle.ApiHandler;
import com.video.main_video.manager.mapper.CollectionsMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Api
public class CollectionsGetListManager implements ApiHandler<CollectionGetListRequest, CollectionsGetListResponse> {

    @Autowired
    CollectionsMapper collectionsMapper;

    @Override
    public CollectionsGetListResponse handler(CollectionGetListRequest collectionGetListRequest) {
        List<Collections> collections = collectionGetList();
        CollectionsGetListResponse res=new CollectionsGetListResponse();
        res.setCollections(collections);
        return res;
    }

    private List<Collections> collectionGetList(){
        LambdaQueryWrapper<Collections> qw=new LambdaQueryWrapper<>();
        qw.eq(Collections::getUserId, StaticData.UserId);
        List<Collections> collections = collectionsMapper.selectList(qw);

        return collections;

    }
}
